﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RoMFramework.Packets
{
    public class PacketBase
    {
        public uint PacketID { get; set; }
        public byte[] Flags { get; set; }
        public uint Size { get; set; }
        public ContentId Content { get; set; }
        public byte[] Bytes { get; set; }
        public Direction PacketDirection { get; set; }

        public PacketBase(byte[] b, Direction d)
        {
            Flags = new byte[4];
            Bytes = b;
            ParseSize();
            PacketDirection = d;
            Content = ContentId.Unknown;
        }

        private void ParseSize()
        {
            if (Bytes.Length >= 0xC)
            {
                Size = uint.Parse(Utilities.BytetoString(Utilities.GetSubByteArray(Bytes, 0x08, 0x04)));
            }
        }
    }

    public enum ContentId
    {
        Unknown = 0x00,
        ObjectSpawn = 0x14,
        ObjectDespawn = 0x15,
        ObjectMove1 = 0x17,
        ObjectMove2 = 0x4C,
        ObjectMove3 = 0x23
    }

    public enum Direction
    {
        Sent,
        Recieved
    }
}